package com.disedu.testdl123.adapter;



import java.util.List;

import com.disedu.testdl123.DlApplication;
import com.disedu.testdl123.model.ProductVo;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class ProductListAdapter extends BaseAdapter {
	private static final String TAG = "ProductListAdapter";
	private Context context ;
	private List<ProductVo> proList ;
	private DlApplication application ;
	
	public ProductListAdapter(Context context,List<ProductVo> proList,DlApplication application) {
		this.context = context;
		this.proList = proList ;
		this.application = application ;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return proList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		ImageView view = null ;
		if(arg1 == null){
			view = new ImageView(context);
		}else {
			view = (ImageView) arg1 ;
		}
		String picPath = proList.get(arg0).getPic() ;
		Log.i(TAG, picPath);
		Bitmap bitmap = application.loadImageFromNetwork(picPath);
		view.setImageBitmap(bitmap);
			
		return view ;
		
	}

}
